﻿//===============================================================================
// La Pomme d'Or Krystal Application
// Windows Presentation Foundation Composite Application 
//===============================================================================
// Copyright (c) Jérôme Piquot.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;

namespace PJ.Data
{
    /// <summary>
    /// <see cref="IEntityData">Entity data</see> persistence provider interface
    /// </summary>
    public interface IEntityProvider : IObjectProvider
    {
        /// <summary>
        /// Gets the data object from the data source
        /// </summary>
        /// <param name="id">Entity id</param>
        /// <param name="mode">Get mode. <see cref="GetDataMode"/> </param>
        /// <returns>The data object</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="id"/> is <see langref="null"/> or empty</exception>
        /// <exception cref="DataNotFoundException">If no entity with this id exists and not in find mode</exception>
        IEntityData GetById(string id, GetDataMode mode);

    }
    /// <summary>
    /// <see cref="IEntityData">Entity data</see> persistence provider interface
    /// </summary>
    /// <typeparam name="TIEntityData"><see cref="IEntityData">Entity data</see> type</typeparam>
    public interface IEntityProvider<TIEntityData> : IObjectProvider<TIEntityData>, IEntityProvider
        where TIEntityData : class, IEntityData
    {
        /// <summary>
        /// Gets the data object from the data source
        /// </summary>
        /// <param name="id">Entity id</param>
        /// <param name="mode">Get mode. <see cref="GetDataMode"/> </param>
        /// <returns>The data object if found or throws an exception</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="id"/> is <see langref="null"/> or empty</exception>
        /// <exception cref="DataNotFoundException">If no entity with this id exists and not in find mode</exception>
        new TIEntityData GetById(string id, GetDataMode mode);

    }
}
